import React, {Component} from 'react';
import {connect} from 'dva';
import moment from 'moment'
import md5 from 'md5'

import {Row,Col} from 'antd'

import style from './home.less'

import {Tabtitle} from '../../../components'
import ToolBar from '../components/ToolBar'

const Performance = ({dispatch,performance,location:{pathname,query}}) =>{
	const tag = `performance`
	const timestamp=parseInt(moment().format('x')/(1000*60*60*8))//8小时
	const sign=md5(`thfx/tgjxpg.cptthfxthfx${timestamp}6f8cda41e3ce45318c4bad855f2abb37`)
	const iframeUrl=`http://168.61.13.30:56780/finereport/ReportServer?reportlet=thfx%2Ftgjxpg.cpt&op=write&platform=thfx&userLogin=thfx&sign=${sign}&begin=${query.begin}&end=${query.end}&group=${query.group}&scene=${query.scene}`

	const group=[
		{
			key:'group1',
			label:'组合一',
		},
		{
			key:'group2',
			label:'组合二',
		},
		{
			key:'group3',
			label:'组合三',
		},
		{
			key:'group4',
			label:'组合四',
		},
	]
	const scene=[
		{
			key:'scene1',
			label:'情景一',
		},
		{
			key:'scene2',
			label:'情景二',
		},
		{
			key:'scene3',
			label:'情景三',
		},
		{
			key:'scene4',
			label:'情景四',
		},
	]
	const exportUrl="http://www.baidu.com"



	/**
	 * 查询报表方法
	 * @param  {[type]} group 组合
	 * @param  {[type]} begin 开始时间
	 * @param  {[type]} end   结束时间
	 * @param  {[type]} scene   场景
	 */
	const searchReport = (group,begin,end,scene) => {
		dispatch({
			type:`${tag}/changeRouter`,
			payload:{
				pathname,
				query:{
					group,
					begin,
					end,
					scene,
				}
			}
		})
	}

	return (
		<div className={`equity ${style.performance}`}>
			<Tabtitle value={'绩效评估报告'}/>
			<div className="content-inner">
				<ToolBar group={group} scene={scene} searchReport={searchReport} query={query} url={exportUrl} />
				<div className={style.mainFrame} style={{height:`${document.documentElement.clientHeight-275}px`}}>
					<iframe
						src={iframeUrl}
						width="100%"
						height="100%"
						frameBorder="0"
						marginWidth="0"
						marginHeight="0"
						allowTransparency="yes"
						></iframe>
				</div>
			</div>
		</div>
	)

}

Performance.propTypes = {
};

export default connect(({performance}) => ({performance}))(Performance);
